import diff from "./diff"

export function updateTextNode(virtualDOM, oldVirtualDOM, oldDOM) {
    if (virtualDOM.props.textContent !== oldVirtualDOM.props.textContent) {
        oldDOM.textContent = virtualDOM.props.textContent
        oldDOM.__virtualDOM = virtualDOM
    }
}
export function updateComponent(virtualDOM, oldComponent, container, oldDOM) {
    oldComponent.componentWillReceiveProps(virtualDOM.props)
    if (!oldComponent.shouldComponentUpdate()) {
        return
    }
    const preProps = oldComponent.props
    oldComponent.componentWillUpdate(virtualDOM.props)
    oldComponent.updateProps(virtualDOM.props)

    const newVirtualDOM = oldComponent.render()
    // newVirtualDOM.component = oldComponent
    diff(newVirtualDOM, container, oldDOM)

    oldComponent.componentDidUpdate(preProps)
}